home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2002 January / maximum-cd-2002-01.iso / Files / Mechwarrior 4 Mapping / MW4Editor.exe / content / ABLScripts / GenericScripts / ArmedConvoy.tpl < prev    next >
Encoding:
Text File  |  2001-07-16  |  6.8 KB  |  198 lines

  1.  
  2. //------------------------------------------------------------------
  3. // NOTE: The fsm name below MUST be changed in order for the
  4. // script to be considered a unique entity!
  5.  
  6. UIFIELDS
  7. {
  8. FIELD<         INT,attackRange,"Attack Range",500>;        // At what range do I start shooting?
  9. FIELD<         INT,withdrawRange,"Withdraw Range",750>;        // At what range do I withdraw from combat entirely?
  10.  
  11. FIELD<          INT,path,"Path",-1>;                // My path
  12. FIELD<          INT,moveType,"Nocycle = 1, Circle = 2, Seesaw = 3",2>;            // How I move along the path
  13.  
  14. FIELD<          INT,piloting,"Piloting Skill",50>;            // Piloting skill
  15. FIELD<          INT,gunnery,"Gunnery Skill",50>;            // Gunnery skill/chance to hit
  16. FIELD<          FLOAT,minDelay,"Minimum fire Delay",1.0>;            // Minimum amount of time I will wait between shots once a weapon is reloaded
  17. FIELD<          FLOAT,maxDelay,"Maximum fire Delay",2.0>;            // Maximum amount of time I will wait between shots once a weapon is reloaded
  18. FIELD<          INT,eliteLevel,"Elite Level",60>;            // Elite level.  This helps determine tactics, defensive manuevers, opportunity fire
  19.                                                     // and other things.  It indicates a general level of combat experience.
  20. FIELD<           INT,isShotRadius,"Is Shot Radius",120>;        // How far away from me will I detect an enemy shot?
  21.         
  22. FIELD<INT, speed,"Movement Speed",600>;        
  23. FIELD<INT,    takeOffDistance,"Take Off Distance (ignored if not a plane)",160>;
  24. FIELD<INT,    attackThrottle,"Percent throttle when in combat",80>;
  25. FIELD<INT,    groupNumber,"What group has this unit been placed in? (in mission script)",11>;
  26. FIELD<INT,    formationType,"What formation type? (from ai.formations in content\ai)",1>;
  27. }
  28.  
  29. fsm Generic_ArmedConvoy : integer;
  30.  
  31.  
  32. //------------------------------------------------------------------
  33.  
  34. // Generic_ArmedConvoy:
  35. //   Follows a path but breaks off to attack enemies.
  36.  
  37. //------------------------------------------------------------------
  38.  
  39.  
  40.  
  41. //------------------------------------------------------------------
  42. //     Constants
  43. //------------------------------------------------------------------
  44.  
  45.     const
  46.         #include_ <content\ABLScripts\mwconst.abi>
  47.  
  48. //------------------------------------------------------------------
  49. //     Types
  50. //------------------------------------------------------------------
  51.  
  52.     type
  53.         #include_ <content\ABLScripts\mwtype.abi>
  54.     
  55.  
  56. //------------------------------------------------------------------
  57. //     Variables
  58. //------------------------------------------------------------------
  59.  
  60.     var
  61.         static integer            attackRange;        // At what range do I start attacking?
  62.         static integer            withdrawRange;        // At what range do I withdraw from combat?
  63.         static integer            groupNumber;        // What's my group -- i.e. I will use GroupObjectID(groupNumber) to identify my group
  64.         static integer            speed;                // The speed at which I move along the path
  65.         static integer            formationType;        // What kind of formation am I in?
  66.         static integer            formationDensity;    // How densely are we packed?
  67.         static integer            path;                // My path
  68.         static integer            moveType;            // How I move along the path
  69.  
  70.         static integer            piloting;            // Piloting skill
  71.         static integer            gunnery;            // Gunnery skill/chance to hit
  72.         static real                minDelay;            // Minimum amount of time I will wait between shots once a weapon is reloaded
  73.         static real                maxDelay;            // Maximum amount of time I will wait between shots once a weapon is reloaded
  74.         static integer             eliteLevel;            // Elite level.  This helps determine tactics, defensive manuevers, opportunity fire
  75.                                                     // and other things.  It indicates a general level of combat experience.
  76.         static integer            attackThrottle;        // My attack throttle
  77.  
  78.          static integer            isShotRadius;        // How far away from me will I detect an enemy shot?
  79.         static integer            findTypes;            // What kind of enemies to look for
  80.  
  81.         static integer             attackSound;        // The attack sound I play when I first attack
  82.         static integer             deathSound;            // The sound I play when I die
  83.         
  84.         static integer            mood;                // My default mood.
  85.  
  86.         static integer            takeOffDistance;    // My take-off distance if I'm an airplane (ignored if not an airplane)
  87.  
  88. //------------------------------------------------------------------
  89. //     Init: my initialization function
  90. //------------------------------------------------------------------
  91.  
  92. function Init;
  93.     code
  94.  
  95.         // Variables set by editor
  96.         attackRange        = <attackRange>;
  97.         withdrawRange    = <withdrawRange>;
  98.         path            = <path>;
  99.         moveType        = <moveType>;
  100.         speed            = <speed>;
  101.         takeOffDistance    = <takeOffDistance>;
  102.          piloting        = <piloting>;
  103.         gunnery            = <gunnery>;
  104.         minDelay        = <minDelay>;
  105.         maxDelay        = <maxDelay>;
  106.         eliteLevel        = <eliteLevel>;
  107.         isShotRadius    = <isShotRadius>;
  108.     attackThrottle    = <attackThrottle>;
  109.         groupNumber        = <groupNumber>;
  110.         formationType    = <formationType>;
  111.  
  112.  
  113.         formationDensity= formtype_sparse;
  114.  
  115.         // driver settings
  116.         attackSound        = -1; // no sound
  117.         deathSound        = -1; // no sound
  118.         mood            = NEUTRAL_START;
  119.         findTypes        = FT_DEFAULT;
  120.  
  121. endfunction;
  122.  
  123. //------------------------------------------------------------------
  124. //    StartState: my initial state
  125. //------------------------------------------------------------------
  126.  
  127. state StartState;
  128.  
  129.     code
  130.         SetFiringDelay            (ME,minDelay,maxDelay);
  131.         SetIgnoreFriendlyFire    (ME,true);
  132.         SetIsShotRadius            (ME,isShotRadius);
  133.         SetEntropyMood            (ME,mood);
  134.         SetCurMood                (ME,mood);
  135.         SetSkillLevel            (ME,piloting,gunnery,eliteLevel);
  136.         SetAttackThrottle        (ME,attackThrottle);
  137.  
  138.         if (orderTakeOff(takeOffDistance) == true) then
  139.             trans FollowPathState;
  140.         endif;
  141.  
  142. endstate;
  143.  
  144. //------------------------------------------------------------------
  145. //    FollowPathState: follow our path, but keep an eye out for enemies
  146. //------------------------------------------------------------------
  147.  
  148. state FollowPathState;
  149.     code
  150.         if (FindEnemy(attackRange,findTypes)) then
  151.             trans AttackState;
  152.         endif;
  153.  
  154.         if (path <> -1) then
  155.             OrderFormationMove((groupobjectid(groupNumber)),path,speed,moveType,formationType,formationDensity,false);
  156.         else
  157.             OrderMoveLookOut;
  158.         endif;
  159. endstate;
  160.  
  161. //------------------------------------------------------------------
  162. //    AttackState: attack my target
  163. //------------------------------------------------------------------
  164.  
  165. state AttackState;
  166.     code
  167.         if (LeaveAttackState(withdrawRange)) then
  168.             OrderStopAttacking;
  169.             SetTarget(ME,NO_UNIT);
  170.             trans FollowPathState;
  171.         endif;
  172.  
  173.         if (attackSound <> -1) then    
  174.             PlaySoundOnce(attackSound);
  175.         endif;
  176.  
  177.         OrderAttack(true);
  178.  
  179. endstate;
  180.  
  181. //------------------------------------------------------------------
  182. //    DeadState: OK, I kicked the bucket.
  183. //------------------------------------------------------------------
  184.  
  185. state DeadState;
  186.     code
  187.         if (deathSound <> -1) then    
  188.             PlaySoundOnce(deathSound);
  189.         endif;        
  190.  
  191.         orderDie;
  192.  
  193. endstate;
  194.  
  195.  
  196. endfsm.
  197.  
  198.